package edu.hunau.cxb19.oop.class28;

import java.nio.CharBuffer;

import org.junit.Test;

/**
 *
 *@author hb
 *
 * 2020-04-07 16:06:49
 */
public class BufferTest {

	@Test
	public void byteBufferTest() {
		//创建一个Buffer
		CharBuffer buff = CharBuffer.allocate(8);//默认容量为8
		System.out.println("capacity:"+buff.capacity());//8
		System.out.println("limit:"+buff.limit());//8
		System.out.println("position:"+buff.position());//0
		//存储数据
		buff.put('a');
		buff.put('b');
		buff.put('c');
		System.out.println("存放abc之后，position:"+buff.position());//3
		buff.flip();
		System.out.println("flip之后，position:"+buff.position());//0
		System.out.println("flip之后，limit:"+buff.limit());//3
		char c01 = buff.get();
		c01=buff.get();
		System.out.println(c01);//b

	}
}
